<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});

//Route::get('{path}', function (\Illuminate\Http\Request $request) {
////拿到路由，查数据库/缓存，想怎么渲染就怎渲染
//    return $request->getPathInfo();
//})->where('path', '.*');

Route::namespace('Api')
    ->prefix('v1')
    ->middleware('cors')
    ->group(function () {

    Route::post('/users/store','UserController@store')->name('users.store');

    Route::post('/login','UserController@login')->name('users.login');

    Route::middleware('api.refresh')->group(function () {
        //当前用户信息
        Route::post('/users/info','UserController@info')->name('users.info');
        //用户列表
        Route::post('/users','UserController@index')->name('users.index');
        //用户信息
        Route::get('/users/{user}','UserController@show')->name('users.show');
        //用户退出
        Route::get('/logout','UserController@logout')->name('users.logout');
    });
});


Route::group([
    'prefix' => 'auth'
], function ($router) {

    Route::post('login', 'AuthController@login');
    Route::post('logout', 'AuthController@logout');
    Route::post('refresh', 'AuthController@refresh');
    Route::post('me', 'AuthController@me');

});
